﻿//==================================================================
// Copyright (C) 2011 深圳市中旭企业管理股份有限公司
// 文件名: wkProjectWorkResult.cs
// 作 者：代码自动生成
// 日 期：2012/10/15 17:35:06
// 描 述：
// 版 本：1.00
// 修改历史纪录
// 版 本  修改时间      修改人            修改内容
// 1.00             
//==================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.Text;
using Csla;
using lite;
using Csla.Validation;
using Csla.Data;
using System.Data.SqlClient;
using ZX.DAL;
using OpenExpressApp.ORM;

namespace ZX.EHR.Library
{
	/// <summary>
    /// 
    /// </summary>
	[Serializable]
    [Table(Name="wkProjectWorkResult")]
    [ZX.DBModule.Table("wkProjectWorkResult","ID")]
	public class wkProjectWorkResult: ZX.DBModule.BaseEntity
	{
        
        #region Business Methods 业务方法
       
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< Guid > IDProperty = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< Guid >("ID"));
        [DataObjectField(true, true)]
        [Column, PK]
        public Guid ID
        {
            get { return GetProperty(IDProperty); }
            set { SetProperty(IDProperty, value); }
        }
        
		/// <summary>
        /// 年月
        /// </summary>
        private static PropertyInfo< string > YearMonthProperty = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("YearMonth"));
        [Column]
        public string YearMonth
        {
            get { return GetProperty(YearMonthProperty); }
            set { SetProperty(YearMonthProperty, value); }
        }
		/// <summary>
        /// 员工ID
        /// </summary>
        private static PropertyInfo< Guid > EmployeeIDProperty = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< Guid >("EmployeeID"));
        [Column]
        public Guid EmployeeID
        {
            get { return GetProperty(EmployeeIDProperty); }
            set { SetProperty(EmployeeIDProperty, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat1Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat1"));
        [Column]
        public string Dat1
        {
            get { return GetProperty(Dat1Property); }
            set { SetProperty(Dat1Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat2Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat2"));
        [Column]
        public string Dat2
        {
            get { return GetProperty(Dat2Property); }
            set { SetProperty(Dat2Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat3Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat3"));
        [Column]
        public string Dat3
        {
            get { return GetProperty(Dat3Property); }
            set { SetProperty(Dat3Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat4Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat4"));
        [Column]
        public string Dat4
        {
            get { return GetProperty(Dat4Property); }
            set { SetProperty(Dat4Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat5Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat5"));
        [Column]
        public string Dat5
        {
            get { return GetProperty(Dat5Property); }
            set { SetProperty(Dat5Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat6Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat6"));
        [Column]
        public string Dat6
        {
            get { return GetProperty(Dat6Property); }
            set { SetProperty(Dat6Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat7Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat7"));
        [Column]
        public string Dat7
        {
            get { return GetProperty(Dat7Property); }
            set { SetProperty(Dat7Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat8Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat8"));
        [Column]
        public string Dat8
        {
            get { return GetProperty(Dat8Property); }
            set { SetProperty(Dat8Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat9Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat9"));
        [Column]
        public string Dat9
        {
            get { return GetProperty(Dat9Property); }
            set { SetProperty(Dat9Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat10Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat10"));
        [Column]
        public string Dat10
        {
            get { return GetProperty(Dat10Property); }
            set { SetProperty(Dat10Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat11Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat11"));
        [Column]
        public string Dat11
        {
            get { return GetProperty(Dat11Property); }
            set { SetProperty(Dat11Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat12Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat12"));
        [Column]
        public string Dat12
        {
            get { return GetProperty(Dat12Property); }
            set { SetProperty(Dat12Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat13Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat13"));
        [Column]
        public string Dat13
        {
            get { return GetProperty(Dat13Property); }
            set { SetProperty(Dat13Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat14Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat14"));
        [Column]
        public string Dat14
        {
            get { return GetProperty(Dat14Property); }
            set { SetProperty(Dat14Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat15Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat15"));
        [Column]
        public string Dat15
        {
            get { return GetProperty(Dat15Property); }
            set { SetProperty(Dat15Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat16Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat16"));
        [Column]
        public string Dat16
        {
            get { return GetProperty(Dat16Property); }
            set { SetProperty(Dat16Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat17Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat17"));
        [Column]
        public string Dat17
        {
            get { return GetProperty(Dat17Property); }
            set { SetProperty(Dat17Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat18Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat18"));
        [Column]
        public string Dat18
        {
            get { return GetProperty(Dat18Property); }
            set { SetProperty(Dat18Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat19Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat19"));
        [Column]
        public string Dat19
        {
            get { return GetProperty(Dat19Property); }
            set { SetProperty(Dat19Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat20Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat20"));
        [Column]
        public string Dat20
        {
            get { return GetProperty(Dat20Property); }
            set { SetProperty(Dat20Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat21Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat21"));
        [Column]
        public string Dat21
        {
            get { return GetProperty(Dat21Property); }
            set { SetProperty(Dat21Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat22Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat22"));
        [Column]
        public string Dat22
        {
            get { return GetProperty(Dat22Property); }
            set { SetProperty(Dat22Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat23Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat23"));
        [Column]
        public string Dat23
        {
            get { return GetProperty(Dat23Property); }
            set { SetProperty(Dat23Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat24Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat24"));
        [Column]
        public string Dat24
        {
            get { return GetProperty(Dat24Property); }
            set { SetProperty(Dat24Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat25Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat25"));
        [Column]
        public string Dat25
        {
            get { return GetProperty(Dat25Property); }
            set { SetProperty(Dat25Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat26Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat26"));
        [Column]
        public string Dat26
        {
            get { return GetProperty(Dat26Property); }
            set { SetProperty(Dat26Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat27Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat27"));
        [Column]
        public string Dat27
        {
            get { return GetProperty(Dat27Property); }
            set { SetProperty(Dat27Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat28Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat28"));
        [Column]
        public string Dat28
        {
            get { return GetProperty(Dat28Property); }
            set { SetProperty(Dat28Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat29Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat29"));
        [Column]
        public string Dat29
        {
            get { return GetProperty(Dat29Property); }
            set { SetProperty(Dat29Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat30Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat30"));
        [Column]
        public string Dat30
        {
            get { return GetProperty(Dat30Property); }
            set { SetProperty(Dat30Property, value); }
        }
		/// <summary>
        /// 
        /// </summary>
        private static PropertyInfo< string > Dat31Property = RegisterProperty(typeof(wkProjectWorkResult),new PropertyInfo< string >("Dat31"));
        [Column]
        public string Dat31
        {
            get { return GetProperty(Dat31Property); }
            set { SetProperty(Dat31Property, value); }
        }
		
        #endregion
        
        #region Validation Rules 验证规则
        //将验证规则与业务对象的属性联系在一起
        protected override void AddBusinessRules()
        {
            //AddRule的第一个参数是委托变量，也就是说是方法的变量
            ValidationRules.AddRule(CommonRules.StringRequired, "YearMonth");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("YearMonth", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat1");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat1", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat2");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat2", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat3");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat3", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat4");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat4", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat5");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat5", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat6");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat6", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat7");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat7", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat8");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat8", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat9");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat9", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat10");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat10", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat11");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat11", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat12");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat12", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat13");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat13", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat14");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat14", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat15");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat15", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat16");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat16", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat17");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat17", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat18");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat18", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat19");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat19", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat20");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat20", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat21");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat21", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat22");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat22", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat23");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat23", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat24");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat24", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat25");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat25", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat26");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat26", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat27");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat27", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat28");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat28", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat29");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat29", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat30");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat30", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "Dat31");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Dat31", 50));
            //base.AddBusinessRules();
        }
        #endregion
        
        #region Factory Methods 工厂方法

        public wkProjectWorkResult(){}

        public static wkProjectWorkResult New()
        {
            return DataPortal.Create< wkProjectWorkResult>();
        }
        public static wkProjectWorkResult Get(Guid ID)
        {
            return DataPortal.Fetch< wkProjectWorkResult>(new SingleLazyCriteria< wkProjectWorkResult, Guid>(ID, false));
        }
        public static void Delete(Guid ID)
        {
            DataPortal.Delete(ID);
        }

        //public override wkProjectWorkResult Save()
        //{
            //return base.Save();
        //}
        #endregion
		
		#region Data Access 数据访问
        //由于DataPortal_create中没有对数据库的访问，所有标记了Runlocal特性，使得该方法只需在本地运行即可
        //如果代码中有访问数据库的方法，那么就不要用这个特性，使数据门户可以根据情况将此方法的运行选择在应用服务器还是本地
        [RunLocal()]
        protected override void DataPortal_Create()
        {
            //在此调用CheckRules对所有的属性进行验证规则的检查，这样检查只运行一次。
            ValidationRules.CheckRules();
        }


        //可以看到此方法没有标记任何特性
        //此方法要访问数据库所以不能标记本地，由于她没有任何数据库更新操作所以也无需事务性的保护
        //此方法调用结束后会隐含的调用MarkOld（）方法
        private void DataPortal_Fetch(Guid ID)
        {
            //通过连接字符串建立SQL连接对象，Using符号代表，范围释放的意思，SqlConnection对象会在此范围后被释放掉
             using (var ctx = ConnectionManager<SqlConnection>.GetManager(ConnectionStringNames))
            {
                IDb db = DbFactory.Instance.GetDb(ctx.Connection);
                IQuery q = db.Query();
                q.Constrain("ID").Equal(ID);
                var data = db.Select< wkProjectWorkResult>(q)[0];
                LoadProperty(IDProperty, data.ID);
                LoadProperty(YearMonthProperty, data.YearMonth);
                LoadProperty(EmployeeIDProperty, data.EmployeeID);
                LoadProperty(Dat1Property, data.Dat1);
                LoadProperty(Dat2Property, data.Dat2);
                LoadProperty(Dat3Property, data.Dat3);
                LoadProperty(Dat4Property, data.Dat4);
                LoadProperty(Dat5Property, data.Dat5);
                LoadProperty(Dat6Property, data.Dat6);
                LoadProperty(Dat7Property, data.Dat7);
                LoadProperty(Dat8Property, data.Dat8);
                LoadProperty(Dat9Property, data.Dat9);
                LoadProperty(Dat10Property, data.Dat10);
                LoadProperty(Dat11Property, data.Dat11);
                LoadProperty(Dat12Property, data.Dat12);
                LoadProperty(Dat13Property, data.Dat13);
                LoadProperty(Dat14Property, data.Dat14);
                LoadProperty(Dat15Property, data.Dat15);
                LoadProperty(Dat16Property, data.Dat16);
                LoadProperty(Dat17Property, data.Dat17);
                LoadProperty(Dat18Property, data.Dat18);
                LoadProperty(Dat19Property, data.Dat19);
                LoadProperty(Dat20Property, data.Dat20);
                LoadProperty(Dat21Property, data.Dat21);
                LoadProperty(Dat22Property, data.Dat22);
                LoadProperty(Dat23Property, data.Dat23);
                LoadProperty(Dat24Property, data.Dat24);
                LoadProperty(Dat25Property, data.Dat25);
                LoadProperty(Dat26Property, data.Dat26);
                LoadProperty(Dat27Property, data.Dat27);
                LoadProperty(Dat28Property, data.Dat28);
                LoadProperty(Dat29Property, data.Dat29);
                LoadProperty(Dat30Property, data.Dat30);
                LoadProperty(Dat31Property, data.Dat31);
            }
        }

        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_DeleteSelf()
        {
            //依然是调用下面的方法删除的，只是他此时可以获得自己的Id
            DataPortal_Delete(IDProperty);
        }
        #endregion

	}
}

